/*
 * libustream: User-space stackable streams
 * @(#) $Id: IUStreamNode.h 2 2009-02-20 09:52:11Z mo@ilaven.net $
 */

/*
 * Copyright (c) 2002, 2008 Mo McRoberts.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The names of the author(s) of this software may not be used to endorse
 *    or promote products derived from this software without specific prior
 *    written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef USTREAM_IUSTREAMNODE_H_
# define USTREAM_IUSTREAMNODE_H_       1

# include "com/com.h"
# include "iri.h"
# include "ustream/IUStream.h"

# undef INTERFACE
# define INTERFACE                     IUStreamNode

DECLARE_INTERFACE_(IUStreamNode, IUnknown)
{
	BEGIN_INTERFACE
	
	STDMETHOD(QueryInterface)(THIS_ com_riid_t riid, void **out) PURE;
	STDMETHOD_(uint32_t,AddRef)(THIS) PURE;
	STDMETHOD_(uint32_t,Release)(THIS) PURE;

	STDMETHOD(GetChildNode)(THIS_ IUStream *parent, IUStream *child, IUStreamNode **childNode) PURE;
	
	STDMETHOD(Write)(THIS_ IUStream *stream, const void *buf, size_t *buflen) PURE;
	STDMETHOD(Read)(THIS_ IUStream *stream, void *buf, size_t *buflen) PURE;
	STDMETHOD(Pending)(THIS_ IUStream *stream, size_t *pending) PURE;
	STDMETHOD(Accept)(THIS_ IUStream *stream, IUStreamNode **out, int *fdout) PURE;

	END_INTERFACE
};

# if defined(COM_CINTERFACE) || !defined(__cplusplus)
#  define IUStreamNode_QueryInterface(__this, riid, out) __this->lpVtbl->QueryInterface(__this, riid, out)
#  define IUStreamNode_AddRef(__this) __this->lpVtbl->AddRef(__this)
#  define IUStreamNode_Release(__this) __this->lpVtbl->Release(__this)
#  define IUStreamNode_GetChildNode(__this, parent, child, childNode) __this->lpVtbl->GetChildNode(__this, parent, child, childNode)
#  define IUStreamNode_Write(__this, stream, buf, buflen) __this->lpVtbl->Write(__this, stream, buf, buflen)
#  define IUStreamNode_Read(__this, stream, buf, buflen) __this->lpVtbl->Read(__this, stream, buf, buflen)
#  define IUStreamNode_Accept(__this, stream, out, fdout) __this->lpVtbl->Accept(__this, stream, out, fdout)
#  define IUStreamNode_Pending(__this, stream, pending) __this->lpVtbl->Pending(__this, stream, pending)
# endif

#endif /* !USTREAM_IUSTREAMNODE_H_ */

/* {6B75DBD6-396D-4988-A65D-E28FAC28F8B3} */
DEFINE_GUID(IID_IUStreamNode, 0x6B75DBD6, 0x396D, 0x4988, 0xA6, 0x5D, 0xE2, 0x8F, 0xAC, 0x28, 0xF8, 0xB3);
